﻿@using Kevin.Shop.Business.Service.Entity.Helper
@using RiderShop.Mobile.ServiceEntity.Purchase
@using Kevin.Shop.Business.SalesManagement.Components.Order
@model  RiderShop.Mobile.Modle.Purchase.CheckOutModel

@section header
{
    <link rel="stylesheet" href="~/Themes/RongJi/Style/base/css/order.css">
    <style>
        .innerwrapper, .pageHeaderMini {
            display: none;
        }

        .checkoutWarpper .pageHeaderMini {
            display: block;
        }

        .section_address .icon_address {
            z-index: 1;
        }

        .address_detail p {
            text-align: left;
        }

        .getbyyourself ul li {
            border-bottom: 1px white solid;
        }

        .borderred {
            border: 2px red solid;
        }
    </style>
}

@section title {
    提交订单
}

<div class="checkoutWarpper">
    <header class="pageHeaderMini">
        <div class="section_address">
            <div id="wrap_address">
                <a href="~/myaccount/ShippingAddress?action=order" class="tbox arrow">
                    <div>
                        <span class="icon_wrap icon_address">&nbsp;&nbsp;&nbsp;&nbsp;</span>
                    </div>
                    <!--本地送礼订单和外地送礼订单不需要出现默认收货地址 -->
                    @if (Model.Behaviour != "isGreetingOrder" && Model.Behaviour != "isGreetingOrderForNonlocal")
                    {
                        if (Model.DefaultShipingAddresses == null)
                        {
                            <div class="address_detail">
                                <p>
                                    <span>
                                        请设置您的收货地址
                                    </span>
                                </p>
                            </div>
                        }
                        else
                        {
                            <div class="address_detail">
                                <p>
                                    <span>
                                        <label>收货人：</label>@Model.DefaultShipingAddresses.ShipTo
                                    </span><span class="fr">@Model.DefaultShipingAddresses.CellPhone</span>
                                </p>
                                <p>@Model.DefaultShipingAddresses.RegionAddress</p>
                                <p>@Model.DefaultShipingAddresses.Address</p>
                            </div>
                        }
                    }
                </a>
            </div>
        </div>
        <!-- InstanceEndEditable -->
    </header>
</div>


<div class="box">


    <form id="submitOrder" method="POST" action="~/Purchase/SubmitOrder">
        <div class="groupbox">
            @foreach (var item in Model.CartInfo.ProductList)
            {

                <div class="OtherTitle">
                    <div class="TitleLeft"><span class="TitleLeftSpan">商品:@item.ProductId</span></div>
                    <div class="TitleRight">
                        <div name="EditQtyAfter" class="ItemQtySpan">
                            <div class="ItemQty">
                                <span class="qtyLable">数量：</span>
                                <div id="Qty_11-119-225" class="QtyTable">@item.Quantity</div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="ItemTable">
                    <div id="OtherProductRight" class="ItemTableRight">
                        <div class="OtherProductItem">
                            <div class="ItemLeft">
                                @if (item.ProductId.Trim() == "COM")
                                {
                                    <img src="http://dev.rongji365.com/Storage/CommResource/COM/COM_100.jpg" alt="" />
                                }
                                else
                                {
                                    <img src="@item.ImageName" alt="" />
                                }
                            </div>
                            <div class="ItemRight"><span class="ItemRightWrod">@item.Title</span></div>
                            <br class="clearfix">
                        </div>
                        <div class="ProductPrice"><span id="prd_price_000" class="Price">@item.Quantity x @item.UnitPrice = ￥@item.SubTotal</span> </div>
                    </div>
                </div>

            }

            <div class="ItemTable">
                <div class="mark_msg">
                    <textarea maxlength="40" id="UserMemo" name="UserMemo" placeholder="备注 限40字以内"></textarea>
                </div>
            </div>



            <div class="OtherTitle">
                <div class="TitleLeft mt10 f15"><i class="glyphicon glyphicon-chevron-right"></i>订单送礼</div>
            </div>
            <div class="ItemTable">
                <div class="OtherProductItem">

                    @if (Model.Behaviour == "isGreetingOrder")
                    {
                        <label>
                            <div>
                                <input class="radio fl" checked type="checkbox" id="IsGreetingOrder" value="true" name="IsGreetingOrder" />
                                <p class="fl">赠送给西安市内的朋友</p>
                            </div>
                        </label><br />
                        <label>
                            <div>
                                <input class="radio fl" type="checkbox" id="IsGreetingOrderForNonlocal" value="false" name="IsGreetingOrderForNonlocal" />
                                <p class="fl">赠送给西安市外的朋友</p>
                            </div>
                        </label>
                    }
                    else if (Model.Behaviour == "isGreetingOrderForNonlocal")
                    {
                        <label>
                            <div>
                                <input class="radio fl" type="checkbox" id="IsGreetingOrder" value="false" name="IsGreetingOrder" />
                                <p class="fl">赠送给西安市内的朋友</p>
                            </div>
                        </label><br />
                        <label>
                            <div>
                                <input class="radio fl" checked type="checkbox" id="IsGreetingOrderForNonlocal" value="true" name="IsGreetingOrderForNonlocal" />
                                <p class="fl">赠送给西安市外的朋友</p>
                            </div>
                        </label>
                    }
                    else
                    {
                        <label>
                            <div>
                                <input class="radio fl" type="checkbox" id="IsGreetingOrder" value="false" name="IsGreetingOrder" />
                                <p class="fl">赠送给西安市内的朋友</p>
                            </div>
                        </label><br />
                        <label>
                            <div>
                                <input class="radio fl" type="checkbox" id="IsGreetingOrderForNonlocal" value="false" name="IsGreetingOrderForNonlocal" />
                                <p class="fl">赠送给西安市外的朋友</p>
                            </div>
                        </label>
                    }

                    @*                            <input type="checkbox" id="IsGreetingOrder" value="@(Model.Behaviour.Equals(" isgreetingorder") ? true
                        false)" name="IsGreetingOrder" />*@

                    <div class="clearfix greetDetail">
                        <p>下单后分享订单给好友由好友填写收货地址，只能在线付款，并且不能自提</p>
                    </div>



                </div>
            </div>

            <div class="OtherTitle">
                <div class="TitleLeft mt10 f15"><i class="glyphicon glyphicon-chevron-right"></i>付款配送信息</div>
            </div>
            <div class="ItemTable">
                <div class="OtherProductItem">
                    @if (Model.Behaviour != "isGreetingOrder" && Model.Behaviour != "isGreetingOrderForNonlocal")
                    {
                        <input type="hidden" id="ShippingId" name="ShippingId" value="@(Model.DefaultShipingAddresses == null ? "0" : Model.DefaultShipingAddresses.ShippingId.ToString())" />
                    }
                    else if (Model.Behaviour == "isGreetingOrder")
                    {
                        <input type="hidden" id="ShippingId" name="ShippingId" value="-1" />
                    }
                    else if (Model.Behaviour == "isGreetingOrderForNonlocal")
                    {
                        <input type="hidden" id="ShippingId" name="ShippingId" value="-2" />
                    }
                    <ul id="Ul1" class="pay_list on">
                        @foreach (var item in Model.OrderShippingType)
                        {
                            if ((Model.Behaviour == "isGreetingOrder" || Model.Behaviour == "isGreetingOrderForNonlocal")
                                && (item.ShippingModeType == ShippingModeType.到付 || item.ShippingModeType == ShippingModeType.自提))
                            {

                            }
                            else
                            {
                                <li>
                                    <label class="tbox">
                                        <div>
                                            <span class="">&nbsp;</span>
                                        </div>
                                        <div>
                                            <p>@item.ShippingModeName</p>
                                            <p>@item.Description</p>
                                        </div>
                                        <div>
                                            <input type="radio" id='@("shippingMode" + item.ShippingModeId)' name="ShippingModeId" value="@item.ShippingModeId" modetype="@((int)item.ShippingModeType)" class="radio ShippingMode" @(item.ShippingModeId == 100 ? "checked" : "") />
                                        </div>
                                    </label>
                                </li>
                            }
                        }
                    </ul>
                </div>
            </div>

            <div class="OtherTitle getbyyourself">
                <div class="TitleLeft mt10 f15"><i class="glyphicon glyphicon-chevron-right"></i>自提地点</div>
            </div>
            <div class="ItemTable getbyyourself">
                <div class="ItemTableRight">
                    <div class="OtherProductItem">
                        <div class="btn-group open">
                            @{

                                List<RiderShop.Mobile.ServiceEntity.MyAccount.UserShipingAddressExtend> defaultPickUps = null;
                                RiderShop.Mobile.ServiceEntity.MyAccount.UserShipingAddressExtend defaultPickUp = new RiderShop.Mobile.ServiceEntity.MyAccount.UserShipingAddressExtend();
                                if (string.IsNullOrEmpty(Request.QueryString["zitidian"]))
                                {
                                    defaultPickUps = RiderShop.Mobile.Modle.MyAccount.MyAccountModel.GetUserPickAddressList(WebClientContext.Current.UserId);
                                }
                                else
                                {
                                    defaultPickUps = RiderShop.Mobile.Modle.MyAccount.MyAccountModel.GetUserPickAddressList(WebClientContext.Current.UserId, 0, 0, int.Parse(Request.QueryString["index"]));
                                }
                                if (defaultPickUps != null && defaultPickUps.Count > 0)
                                {
                                    defaultPickUp = defaultPickUps[0];
                                }
                            }


                            <ul id="Ul1" class="pay_list on">

                                <li>
                                    <a id="select_pickup" href="/MyAccount/PickUpAddress">
                                        <label class="tbox">
                                            <div>
                                                <span class="">&nbsp;</span>
                                            </div>

                                            <div>
                                                <p>@defaultPickUp.ShipTo</p>
                                                <p>@(defaultPickUp.RegionAddress + defaultPickUp.Address)</p>
                                            </div>


                                            <div>
                                                <span class="glyphicon glyphicon-chevron-right f25 fr"></span>
                                            </div>
                                        </label>
                                    </a>
                                </li>
                            </ul>
                            <input name="PickUpAddressId" type="hidden" id="regionId" value="@defaultPickUp.ShippingId">
                            <input name="PickUpAddressInfo" type="hidden" id="regionText" value="@(defaultPickUp.ShipTo + ": " + defaultPickUp.RegionAddress + defaultPickUp.Address)">
                        </div>
                    </div>
                </div>
            </div>
            <input type="hidden" value="0" id="ArrivePay" name="ArrivePay" />
            @*<div class="OtherTitle">
                    <div class="TitleLeft mt10 f15"><i class="glyphicon glyphicon-chevron-right"></i>支付方式</div>
                </div>
                <div class="ItemTable">
                    <div class="ItemTableRight">
                        <div class="OtherProductItem">
                            <input type="hidden" id="txtPayType" value="@WebClientContext.Current.OnLinePayment" />
                            <input type="hidden" name="PaymentType" value="@((int)WebClientContext.Current.OnLinePayment)" />
                            @if (WebClientContext.Current.OnLinePayment != PaymentType.PointPay)
                            {
                                <ul id="Ul1" class="pay_list on">
                                    @if (!Model.CartInfo.ProductList.Any(p => "10330002013 10330002014 10330002015".Contains(p.ProductId)))
                                    {

                                        if (Model.Behaviour != "isGreetingOrder")
                                        {
                                            <li>
                                                <label class="tbox">
                                                    <div>
                                                        <span class="">&nbsp;</span>
                                                    </div>
                                                    <div>
                                                        <p>货到付款</p>
                                                        <p>仅支持鲜享卡货到付款</p>
                                                    </div>
                                                    <div>
                                                        <input type="radio" id="ridPaymentTypeArrivePay" name="ArrivePay" value="1" class="radio PaymentType" @(WebClientContext.Current.OnLinePayment != PaymentType.OnlinePay ? "checked" : "")>
                                                    </div>
                                                </label>
                                            </li>
                                        }
                                    }
                                    <li>
                                        <label class="tbox">
                                            <div>
                                                <span class="">&nbsp;</span>
                                            </div>
                                            <div>
                                                <p>在线付款</p>
                                                <p>推荐使用鲜享卡在线支付</p>
                                            </div>
                                            <div>
                                                <input type="radio" id="ridPaymentTypeOnlinePay" name="ArrivePay" value="0" class="radio PaymentType" @(WebClientContext.Current.OnLinePayment == PaymentType.OnlinePay ? "checked" : "")>
                                            </div>
                                        </label>
                                    </li>
                                </ul>
                            }
                        </div>
                    </div>
                </div>

                <div class="OtherTitle PaymentTypeDetail">
                    <div class="TitleLeft mt10 f15"><i class="glyphicon glyphicon-chevron-right"></i>在线支付</div>
                </div>
                <div class="ItemTable PaymentTypeDetail">
                    <div class="ItemTableRight">
                        <div class="OtherProductItem">
                            <ul id="pay_list" class="pay_list on">
                                <li>
                                    <label class="tbox">
                                        <div>
                                            <span class="pay_offlinepay">&nbsp;</span>
                                        </div>
                                        <div>
                                            <p>鲜享卡</p>
                                            <p>下单后使用鲜享卡号密码在线付款</p>
                                        </div>
                                        <div>
                                            <input type="radio" id="payrongjicart" name="PaymentGateway" value="rongjicart" class="radio">
                                        </div>
                                    </label>
                                </li>
                                @if (Request.UserAgent.Contains("MicroMessenger"))
                                {
                                    <li>
                                        <label class="tbox">
                                            <div>
                                                <span class="pay_weipay">&nbsp;</span>
                                            </div>
                                            <div>
                                                <p>微信支付</p>
                                                <p>推荐微信用户使用</p>
                                            </div>
                                            <div>
                                                <input type="radio" id="WeixinPay" name="PaymentGateway" value="WeixinPay" class="radio" checked="checked">
                                            </div>
                                        </label>
                                    </li>
                                    <li>
                                        <label class="tbox">
                                            <div>
                                                <span class="pay_alipay">&nbsp;</span>
                                            </div>
                                            <div>
                                                <p>支付宝</p>
                                                <p>推荐已开通支付宝的用户使用</p>
                                            </div>
                                            <div>
                                                <input type="radio" id="AliPay" name="PaymentGateway" value="AliPay" class="radio">
                                            </div>
                                        </label>
                                    </li>
                                }
                                else
                                {
                                    <li>
                                        <label class="tbox">
                                            <div>
                                                <span class="pay_alipay">&nbsp;</span>
                                            </div>
                                            <div>
                                                <p>支付宝</p>
                                                <p>推荐已开通支付宝的用户使用</p>
                                            </div>
                                            <div>
                                                <input type="radio" id="AliPay" name="PaymentGateway" value="AliPay" class="radio" checked="checked">
                                            </div>
                                        </label>
                                    </li>
                                }
                                <ol class="show_all" onclick="$('#pay_list').addClass('on');">
                                    <a href="javascript:;" class="arrow">更多支付方式</a>
                                </ol>


                                <li>
                                    <label class="tbox">
                                        <div>
                                            <span class="pay_unionpay">&nbsp;</span>
                                        </div>
                                        <div>
                                            <p>银联全民付</p>
                                            <p>即将开通，尽请期待</p>
                                        </div>
                                        <div>
                                            <input type="radio" disabled="disabled" name="paytype" value="18705" class="radio">
                                        </div>
                                    </label>
                                </li>

                            </ul>
                        </div>
                    </div>
                </div>*@


            @{

                var promotionCodeList = Model.PromotionCodeList;
                if (promotionCodeList == null || promotionCodeList.Count == 0
                    || (Model.CartInfo.ProductList.All(p => "10330002013 10330002014 10330002015".Contains(p.ProductId))))
                {
                    <div class="OtherTitle">
                        <div class="TitleLeft mt10 f15"><i class="glyphicon glyphicon-chevron-right"></i>优惠券</div>
                    </div>
                    <div class="ItemTable">
                        <div class="ItemTableRight">
                            <div class="OtherProductItem">
                                <p>很遗憾当前订单没有可用优惠券，快去领取吧！</p>
                            </div>
                        </div>
                    </div>
                }
                else
                {
                    <div class="OtherTitle">
                        <div class="TitleLeft mt10 f15"><i class="glyphicon glyphicon-chevron-right"></i>优惠券 - <i style="color: red">您有 @promotionCodeList.Count 张优惠券，点击使用吧</i></div>
                    </div>
                    <div class="ItemTable">
                        <div class="ItemTableRight">
                            <div class="OtherProductItem">
                                <select id="PromotionCode" name="PromotionCode" class="select">
                                    <option value="" selected>优惠券</option>
                                    @for (int i = 0; i < promotionCodeList.Count; i++)
                                    {
                                        var pro = promotionCodeList[i];
                                        <option value="@pro.UserCardCode" @(i == 0 ? "selected" : "")>@(pro.CouponName + (pro.PromotionType == 1 ? " - " + pro.CodeDiscount.ToString("N0") + "元" : ""))</option>
                                    }
                                </select>
                            </div>
                        </div>
                    </div>

                }
            }


            <div class="OtherTitle">
                <div class="TitleLeft mt10 f15"><i class="glyphicon glyphicon-chevron-right"></i>鲜豆</div>
            </div>
            <div class="ItemTable">
                <div class="OtherProductItem">
                    <input id="OrderExpensePoint" type="hidden" name="OrderExpensePoint" value="0" />
                    <div class="switchWrapper clearfix" id="usePointGroup">
                        <div class="sitem-l">
                            <p>可用<span id="usePoint">0</span>鲜豆，抵￥<span id="usePointMoney">0.00</span>元</p>
                        </div>
                        <div class="sitem-r">
                            <div id="usePointIcon" class="switch"> </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>

    <div class="checkoutDiscount tline">
        <div class="total">
            <div class="totalinfo">
                <p><span class="tit">小计：</span><span class="case">@Model.CartInfo.ProductPriceAmount</span></p>
                <p><span class="tit">运费金额：</span><span id="ShippingCharge" class="case">@Model.CartInfo.ShippingCharge</span></p>
                <p><span class="tit">折扣小计：</span><span id="DiscountAmount" class="case green">- @Model.CartInfo.DiscountAmount</span></p>
                <p><span class="tit">鲜豆抵扣：</span><span id="ExpenseAmount" class="case green">- @Model.CartInfo.ExpenseAmount</span></p>
                <p class="all"><span class="tit">应付金额：</span><span id="PayAmount">@Model.CartInfo.PayAmount </span></p>
            </div>
        </div>
    </div>
    <div class="fixed-me">
        <div class="allpay">
            <span class="tit">应付金额：</span><span id="FinalPayAmount">@Model.CartInfo.PayAmount </span>
        </div>
        <form id="toCompleted" method="POST" action="~/Purchase/OrderCompleted">
            <a href="javascript:;" class="btn btn-danger btn-block bmargin mb10" id="submitorder">提交订单</a>
        </form>
        <form id="orderBalanceCompute" method="POST" action="~/Purchase/OrderBalanceCompute"></form>
    </div>

</div>
@section footer
{
    <script type="text/javascript" src="~/Utility/pages/pg_purchase.js"></script>

    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            //配送方式类型
            var shippingModeType = 0;

            //点击地图跳转回来
            var zitidian = "@Request.QueryString["zitidian"]";
            var zitidianIndex = "@Request.QueryString["index"]";

            var orderData = { "ArrivePay": 0, "DiscountAmount": 0, "GiftCardList": [], "OrderExpensePoint": 0, "OrderGiftCardAmount": 0, "OrderPayAmount": 0, "OrderStatus": 0, "OrderTotalAmount": 0, "PaymentType": 1, "ProductList": [], "ReceiveAddress": "", "ReceiveCellPhone": "", "ReceiveDate": null, "ReceivePhone": "", "ShippingCharge": 0, "ShippingId": 0, "UserMemo": "", "PromotionCode": "", "PaymentGateway": "", "IsGreetingOrder": false, "PickUpAddressId": 0, "PickUpAddressInfo": "", "IsGreetingOrderForNonlocal": false };
            var multiSubmit = 0;
            var shiptype = $("input[name='ShippingModeId']:checked").val();
            //alert(shiptype);
            //var paymentType = $("input[name='ArrivePay']:checked").val();
            $("#submitorder").click(function () {
                submitOrder();
            });

            //选中配送方式
            $(".ShippingMode").click(function () {
                shiptype = $(this).val();
                BalanceCompute();
                refreshGetByself();
            });

            $("#ShippingId").change(function () {
                BalanceCompute();
            });
            //$(".PaymentType").click(function () {
            //    paymentType = $(this).val();
            //    refreshPaymentType();
            //});

            $("#PromotionCode").change(function () {
                BalanceCompute();
            });
            //var refreshPaymentType = function () {
            //    if (paymentType && paymentType === "0") {
            //        $(".PaymentTypeDetail").show();
            //    } else {
            //        $(".PaymentTypeDetail").hide();
            //    }
            //};

            //使用鲜豆
            $('#usePointGroup').click(function () {
                var icon = $('#usePointIcon');
                var pointMoney = parseFloat($('#usePointMoney').text());

                if (parseFloat(pointMoney) <= 0) {
                    return;
                }

                if (icon.hasClass('switched')) {
                    icon.removeClass('switched');
                    $('#OrderExpensePoint').val(0);
                }
                else {
                    icon.addClass('switched');
                    $('#OrderExpensePoint').val($('#usePoint').html());
                }

                BalanceCompute(true)
            });

            var submitOrder = function () {
                //alert(shiptype);
                if (multiSubmit == 1) {
                    return false;
                }
                //检查
                KevinShop.Common.ShoppingCart.RefreshTotalQty();
                if (KevinShop.Common.ShoppingCart.TotalQty == 0) {
                    KevinShop.MessageBox.Alert("购物车至少得有一个商品。");
                    return false;
                }
                //var points = $('#usingPoints').val();
                //if(validPoint != points) {
                //    KevinShop.MessageBox.Alert("当您想使用账户余额抵扣订单金额，别忘了点击旁边的“使用”按钮，方能生效，谢谢。");
                //    return;
                //}
                if (!shiptype) {
                    KevinShop.MessageBox.Alert("请选择配送方式。");
                    return false;
                }

                //本地礼品订单 & 外地礼品订单不去检查收货人信息
                if (!$("#IsGreetingOrder").prop('checked') && !$("#IsGreetingOrderForNonlocal").prop('checked')) {
                    //Greeting Order not check shippingid
                    if ($("input[name='ShippingId']").attr("value") == "" || $("input[name='ShippingId']").attr("value") == "0") {
                        $("#wrap_address").addClass('borderred');
                        $("html, body").animate({ scrollTop: 0 }, "slow");
                        KevinShop.MessageBox.Alert("请选择收货人。");
                        return false;
                    }
                }

                if (shippingModeType === "3") {//自提
                    if (!$('#regionId').val()) {
                        KevinShop.MessageBox.Alert("请选择自提点。");
                        return false;
                    }
                }

                //var payType = $("#txtPayType").val();
                //if (payType == "PointPay" || payType == "AllPayment") {
                //    var point = Number($("#pointPay").val());
                //    var current = Number($("#currentPoint").text());

                //    if (point == 0 || point == NaN) {
                //        KevinShop.MessageBox.Alert("鲜豆必须大于0，请检查。");
                //        return false;
                //    }
                //    else if (point > 0 && point > current) {
                //        KevinShop.MessageBox.Alert("您的鲜豆不足。");
                //        return false;
                //    }
                //    orderData.OrderExpensePoint = Number($("#pointPay").val());

                //} else if (!paymentType) {
                //    KevinShop.MessageBox.Alert("请选择支付方式。");
                //    return false;
                //}

                //if (!$("input[name='PaymentGateway']:checked").val()) {
                //    KevinShop.MessageBox.Alert("请选择支付方式。");
                //    return false;
                //}

                //if ($('#IsInvoice').attr("checked")) {
                //    if ($('#InvoiceTitle').val() == "") {
                //        KevinShop.MessageBox.Alert("请填写发票抬头。");
                //        return;
                //    }
                //}
                //获取form表单

                var order = KevinShop.Common.FormToObj($('#submitOrder'), orderData);

                var newOrderData = KevinShop.Common.EvalJSON(order);
                if (newOrderData.IsGreetingOrderForNonlocal) {
                    newOrderData.IsGreetingOrder = true;
                    order = KevinShop.Common.ToJSON(newOrderData);
                }
                if (shippingModeType === "3") {//自提-
                    var newdata = KevinShop.Common.EvalJSON(order);
                    newdata.UserMemo = (newdata.UserMemo ? newdata.UserMemo : "") + encodeURI(" 自提地点： " + $('#regionText').val());
                    order = KevinShop.Common.ToJSON(newdata);
                }
                else {
                    var newdata = KevinShop.Common.EvalJSON(order);
                    newdata.PickUpAddressId = 0;
                    newdata.PickUpAddressInfo = '';
                    order = KevinShop.Common.ToJSON(newdata);
                }

                //if ($('input:radio[name="PaymentGateway"]:checked').val() == "rongjicart") {
                //    var chekckOrder = KevinShop.Common.EvalJSON(order);
                //    chekckOrder.UserMemo = (chekckOrder.UserMemo ? chekckOrder.UserMemo : "") + escape(" 使用蓉记鲜享卡付款");
                //    chekckOrder.ArrivePay = 1;
                //    order = KevinShop.Common.ToJSON(chekckOrder);
                //}

                var url = document.forms["submitOrder"].action;
                KevinShop.Common.Ajax.Post(url, order, function (data) {
                    if (data.error) {
                        KevinShop.MessageBox.Alert(data.error);
                        return;
                    }
                    if (!data.Status) {

                        KevinShop.MessageBox.Alert(data.ErrorMessage);
                        return;
                    }
                    var completeUrl = document.forms["toCompleted"].action;
                    window.location = completeUrl + "?par=" + data.Tag;
                }, false);
                multiSubmit = 0;
                return false;
            };
            var RefreshGiftCardList = function (html) {
                var div = $('#giftCardList');
                $(div).empty();
                $(div).html(html);
                //刷新订单金额
                Kevin.AjaxMethod.RefreshAmount(function (data) {
                    RefreshOrderAmount(data);
                });
            };

            var BalanceCompute = function (isUsePoint) {


                //     if ($("#ShippingId") && $("#ShippingId").val().length != 0
                //        && shiptype) {
                var shippingId = $("#ShippingId").val();
                var promotionCode = $("#PromotionCode").val();
                if (!promotionCode) {
                    promotionCode = 0;
                }
                var url = document.forms["orderBalanceCompute"].action;

                var point = isUsePoint ? $('#OrderExpensePoint').val() : "0";

                //int shiptype, int shippingId
                url = url + "?shiptype=" + shiptype + "&shippingId=" + shippingId + "&promotionCode=" + promotionCode + "&point=" + point;
                KevinShop.Common.Ajax.Get(url, function (data) {
                    RefreshOrderAmount(data);
                });
                //    }
            };
            BalanceCompute();

            var RefreshOrderAmount = function (data) {
                if (!data) {
                    return;
                }
                $('#ShippingCharge').text(data.ShippingCharge.toFixed(2));
                $('#DiscountAmount').text('- ' + data.DiscountAmount.toFixed(2));
                $('#PayAmount').text(data.PayAmount.toFixed(2));
                $('#FinalPayAmount').text(data.PayAmount.toFixed(2));
                $('#GiftCardAmount').text('- ' + data.GiftCardAmount.toFixed(2));
                $('#ExpenseAmount').text('- ' + data.ExpenseAmount.toFixed(2));

                //鲜豆
                $('#usePoint').html(data.MaxExpensePoint);
                $('#usePointMoney').html(data.MaxExpenseAmount.toFixed(2));
                if (data.ExpensePoint === 0) {
                    $('#usePointIcon').removeClass('switched');
                    $('#OrderExpensePoint').val(0);
                }
            };
            //refreshPaymentType();

            $('#vshopRegion ul li a').click(function () {

                var code = $(this).attr('name');
                var address = $(this).html();
                $("#address-check-btn").html(code + "<span class='caret'></span>");
                $('#regionId').val(code);
                $('#regionText').val(' 自提地点： ' + address);
            });
            var refreshGetByself = function () {
                shippingModeType = $("input[name='ShippingModeId']:checked").attr("modeType");
                if (shippingModeType === "3") {
                    $(".getbyyourself").show();

                    //$("#ridPaymentTypeArrivePay").prop('disabled', true);
                    //$("#ridPaymentTypeOnlinePay").prop('checked', true);
                    //paymentType = $("#ridPaymentTypeOnlinePay").val();
                } else {
                    $(".getbyyourself").hide();
                    //$("#ridPaymentTypeArrivePay").prop('disabled', false);
                }
                if (shippingModeType === "2") {
                    $("#ArrivePay").val("1");
                }
                else {
                    $("#ArrivePay").val("0");
                }
                //refreshPaymentType();
            };
            refreshGetByself();

            if (zitidian != '' && zitidianIndex != '') {
                $("#shippingMode101").attr('checked', 'true');
                shiptype = $("input[name='ShippingModeId']:checked").val();
                BalanceCompute();
                refreshGetByself();
            }
        });

        function Convert_GCJ02_To_BD09(lng, lat) {
            var x_pi = 3.14159265358979324 * 3000.0 / 180.0;
            var x = lng;
            var y = lat;
            var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
            var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);

            lng = z * Math.cos(theta) + 0.0065;
            lat = z * Math.sin(theta) + 0.006;

            var arrZuoBiao = [lng, lat];

            return arrZuoBiao;
        }

        if (typeof (wx) !== 'undefined') {
            wx.ready(function () {
                wx.getLocation({
                    success: function (res) {
                        var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
                        var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
                        var speed = res.speed; // 速度，以米/每秒计
                        var accuracy = res.accuracy; // 位置精度

                        //alert('为转换前的微信坐标：经度' + longitude + " 纬度:" + latitude);

                        var arrZuoBiao = Convert_GCJ02_To_BD09(longitude, latitude);

                        longitude = arrZuoBiao[0];
                        latitude = arrZuoBiao[1];
                        //alert('为转换后的百度坐标：经度' + longitude + " 纬度:" + latitude);

                        //alert(latitude);

                        var select_pickup = $("#select_pickup")
                        select_pickup.attr('href', select_pickup.attr('href') + '?lng=' + longitude + '&lat=' + latitude);

                    },
                    fail: function (res) {
                    },
                    cancel: function (res) {
                    }
                });
            });
        }
    </script>

    @if (Model.CartInfo.CommonProductListNoCOM.Any(p => p.GiftShippingType != 1))
    {

        var sb = new System.Text.StringBuilder();
        Model.CartInfo.CommonProductListNoCOM.Where(p => p.GiftShippingType != 1).ToList().ForEach(p => { sb.Append(p.Title + "、"); });

        <script type="text/javascript" language="javascript">
            $(document).ready(function () {

                $("#IsGreetingOrder").click(function () {
                    $("#IsGreetingOrder").prop('checked', false);
                    KevinShop.MessageBox.Alert("商品 @sb.Remove(sb.Length - 1, 1).ToString() 不支持礼品订单。");


                });

                $("#IsGreetingOrderForNonlocal").click(function () {
                    $("#IsGreetingOrderForNonlocal").prop('checked', false);
                    KevinShop.MessageBox.Alert("商品 @sb.Remove(sb.Length - 1, 1).ToString() 不支持礼品订单。");


                });

            });
        </script>
    }
    else
    {


        <script type="text/javascript" language="javascript">
            $(document).ready(function () {
                //选中本地送礼订单
                $("#IsGreetingOrder").click(function () {
                    //提交按钮单击事件失效，防止在页面跳转的过程中，去提交订单
                    $("#submitorder").unbind("click");
                    if ($("#IsGreetingOrder").prop('checked')) {
                        window.location.href = '/Purchase/CheckOut?behaviour=isGreetingOrder';
                        return false;
                        //不能鲜享卡支付 & 上门自提
                        //$("#payrongjicart").prop("disabled", true);
                        //$("#shippingMode101").prop("disabled", true);
                    }
                    else {
                        window.location.href = '/Purchase/CheckOut';
                        return false;
                        //$("#payrongjicart").prop("disabled", false);
                        //$("#shippingMode101").prop("disabled", false);
                    }
                });

                //选中外地送礼订单
                $("#IsGreetingOrderForNonlocal").click(function () {
                    //提交按钮单击事件失效，防止在页面跳转的过程中，去提交订单
                    $("#submitorder").unbind("click");
                    if ($("#IsGreetingOrderForNonlocal").prop('checked')) {
                        window.location.href = '/Purchase/CheckOut?behaviour=isGreetingOrderForNonlocal';
                        return false;
                    }
                    else {
                        window.location.href = '/Purchase/CheckOut';
                        return false;
                    }
                });
            });
        </script>

    }


}





